%  The style option file "deleq.sty" is found after these instructions,
%  right before the .sty-file is a line with 30 percentage-signs.
%
% 
%                   LaTeX Macro for Partial Numbering of Equations
%                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% 
%                   by Mats Dahlgren, <matsd@physchem.kth.se> 
%                      or <mats@fenk.wau.nl>,  June 1994
% 
%                       Version 3.0, June 22, 1994
% 
% deleq.sty is a LaTeX macro makes partial numbering of equations
% possible.  It is meant to be used when numbering such as 3a, 3b, etc.
% is desired.  The default is to give an equation number like '3a'
% without period and with the 'a' typeset in roman font.  It can be used
% in 'article' as well as 'book' and 'report' document styles.  The
% examples given below are valid for 'article' styled documents.
% Both right aligned and left aligned equation numbers are avaliable.
% Equations can be numbered either 3, 3a, 3b, ..., or 2, 3a, 3b, ....
% Also, if equation numbers within eqnarray-like environments can be
% numbered 3, 3a, 3b,... or starting at 3a, which can follow both after
% equation 2b or 3.  An array environment can have its first equation
% numbered 3b if the nearest previous equation is 3a.  Within the
% array environment, equations can be numbered 3a, 3b, 4, 4a, 4b, 5a, 5b,
% etc., and also not numbered lines are possible ('\nonumber' works).
% Furthermore, equation numbers can be "recycled".  If equation 3 is repeated
% after equation 8, it can still have the numbering set to 3, and be
% followed by (a new) equation 9.  "Recycled" equation numbers can 
% receive partial numbers (3a, 3b, ...); partially numbered equations
% can also be "recycled" (but at this stage, the latter can not receive
% new partial numbers neatly, it will come out like '3ba' if eqution 3b
% is the "recycled" equation).  A command for using references in mathmode
% which avoids the eroor message "Don't use \bf in mathmode" when processed
% is also included. 
% 
% deleq.sty version 3.0 has been tested with LaTeX 2.09 under UNIX.  Please
% send bug reports, corrections, additions, suggestions, etc to me at
% <matsd@physchem.kth.se>.  Use the file at your own pleasure and risk.
% (Command names are a mixture of LaTeX, Swedish and a bit of the author's 
% fantasy...)
% 
% Enjoy your LaTeX!
%                   mats d.
% 
% 
% Requirements:     The file 'deleq.sty' must be available in the user's
%                  'TEXINPUTS' directories.
% 
% Usage:            The macro is included by stating 'deleq' as one of the 
%                   options with the '\documentstyle' command.
% 
% Environments:     The macro defines the following eight environments:
%                   deqn           environment for automatic numbering of the
%                                  first equation of type 3a
%                   dleqn          'deqn' for left-aligned numbers
%                   ddeqn          used for automatic numbering of the 
%                                  equations following the one in 'deqn';
%                                  see also details below 
%                   ddleqn         'ddeqn' for left-aligned numbers
%                   deqarr         environment for automatic partial equation
%                                  numbering used in 'eqnarray' environment
%                   dleqarr        'deqarr' for left-aligned numbers
%                   ddeqar         similar to 'deqarr' environment, but more 
%                                  flexible, see details below
%                   ddleqar        'ddeqar' for left-aligned numbers
% 
% Commands:         The macro defines the following thirteen commands:
%                   \nydeqno
%                   \heqno
%                   \nydeleqno
%                   \nydelleqno
%                   \deleqno
%                   \delleqno
%                   \reqno{FOO}
%                   \rleqno{FOO}
%                   \rndeqno{FOO}
%                   \rndleqno{FOO}
%                   \rdeqno{FOO}
%                   \rdleqno{FOO}
%                   \mthref{FOO}
% 
% Notice:       1.  If you use '\nydeleqno', '\nydelleqno', '\deleqno', 
%                   '\delleqno', \nydeqno', '\heqno', '\reqno', '\rleqno'
%                   '\rndeqno', '\rndleqno', '\rdeqno', or '\rdleqno' in 
%                   combination with '\label{FOO}', '\label{FOO}' should
%                   appear after the 'deleq'-command;
%               2.  If you change the appearance of equation numbers (e.g. use
%                   '[2]' instead of '(2)'),  deleq':s commands may not typeset
%                   the partial equation numbers like your ordinary ones.
% 
% Syntax:           Here follows a more detailed description of the different
%                   environments and commands.
% 
%   \begin{deqn}    typesets an equation just like \begin{equation} .. 
%   ..\end{deqn}    \end{equation} does, but gives it a number such as
%                   '3a' instead of '3' (always 'a').
% 
%   \begin{dleqn}   typesets an equation just like \begin{deqn} .. \end{deqn}
%   ..\end{dleqn}   does, but with the equation number left-aligned.
% 
%   \begin{ddeqn}   typesets an equation just like \begin{equation} .. 
%   ..\end{ddeqn}   \end{equation} does, but gives it a number such as
%                   '3b', '3c'... instead of '3', '4'... when following after
%                   another partially numbered equation.  When following 
%                   after an ordinarily numbered equation ('3') it gives
%                   a partial equation number with the last used ordinary
%                   equation number, e.g. '3a'.  Can be made to produce the
%                   result of 'deqn' environment by the use of '\nydeqno'.
% 
%   \begin{ddleqn}  typesets an equation just like \begin{ddeqn} .. \end{ddeqn}
%   ..\end{ddleqn   does, but with the equation number left-aligned.
% 
%   \begin{deqarr}  typesets an equation array just like \begin{eqnarray} .. 
%   ..\end{deqarr}  \end{eqnarray} does, but gives the first numbered 
%                   equation a number like '3a' instead of '3' (always 'a'),
%                   and the following '3b', '3c' etc.  The '\nonumber' command
%                   works just like in the 'equationarray' environment.
% 
%   \begin{dleqarr} typesets an equation array just like \begin{dleqarr} .. 
%   ..\end{dleqarr} \end{dleqarr} does, but with the equation numbers
%                   left-aligned.
% 
%   \begin{ddeqar}  typesets an equation array just like \begin{eqnarray} .. 
%   ..\end{ddeqar}  \end{eqnarray} does, but gives the equation numbers such
%                   as '3a' if following after an equation numbered '3' 
%                   (ordinary equation number) and numbers such as '3c' if
%                   following after a partially numbered equation '3b'. 
%                   Can be made to produce the result of 'deqarr' environment 
%                   by the use of '\nydeqno'.  The '\nonumber' command
%                   works just like in the 'equationarray' environment.
% 
%   \begin{ddleqar} typesets an equation array just like \begin{ddleqar} .. 
%   ..\end{ddleqar} \end{ddleqar} does, but with the equation numbers
%                   left-aligned.
% 
%   \nydeqno        Used within 'deqarr', 'dleqarr', 'ddeqar', or 'ddleqar' 
%                   environments to step the main equation number by one 
%                   and reset the partial equation number to 'a'; thus,   
%                   '\nydeqno' gives equation number '4a' when following 
%                   equation '3c'.
% 
%   \heqno          Used within 'deqarr', 'dleqarr', 'ddeqar', or 'ddleqar' 
%                   environments to step the main equation number by one and  
%                   to produce an ordinary equation number; thus, gives 
%                   equation number '4' when following equation '3c'. 
%                   Equations following the '\heqno'-ed will be partially  
%                   numbered with the '\heqno'-ed equation's number as the
%                   main number, e.g. '4a' (unless it has a '\nydeqno' 
%                   command, which in this case would produce the equation 
%                   number '5a').
% 
%   \nydeleqno      gives a new partial equation number when used in $$ ... $$.
%                   Thus, writing '$$ ... \nydeleqno $$' is equivalent to 
%                   writing '\begin{deqn} ... \end{deqn}'.
% 
%   \nydelleqno     gives a new partial left-aligned equation number when 
%                   used in $$ ... $$. Thus, writing '$$ ... \nydelleqno $$'  
%                   is equivalent to writing '\begin{dleqn} ... \end{dleqn}'.
% 
%   \deleqno        gives a partial equation number when used in $$ ... $$.
%                   Thus, writing '$$ ... \deleqno $$' is equivalent to 
%                   writing '\begin{ddeqn} ... \end{ddeqn}'.
% 
%   \delleqno       gives a partial left-aligned equation number when 
%                   used in $$ ... $$. Thus, writing '$$ ... \delleqno $$'  
%                   is equivalent to writing '\begin{ddleqn} ... \end{ddleqn}'.
% 
%   \reqno{FOO}     is used when repeating equations with its original number.
%                   '\reqno' takes the argument 'FOO', which has to be defined
%                   by a '\label{FOO}' in the original equation.  It can
%                   only be used within $$ ... $$.  It does not affect the 
%                   equation number counter, nor the partial equation number 
%                   counter.  However, it resets the partial equation number
%                   counter for the '\rndeqno', '\rndleqno', '\rdeqno', and 
%                   '\rdleqno' commands.  If used with a '\label{FOOO}' 
%                   command, the .aux-file will only contain the page number 
%                   of label {FOOO}.
% 
%   \rleqno{FOO}    same as '\reqno{FOO}' but left-aligns the equation number.
% 
%   \rndeqno{FOO}   adds a partial equation number to an old equation number,
%                   specified by the FOO label.  If FOO refers to equation 
%                   '4', '\rdeqno{FOO}' will result in equation number '4a'
%                   (always 'a').  It can only be used within 
%                   $$ ... $$.  It does not affect the equation number counter,
%                   nor the partial equation number counter.  However, it
%                   resets the partial equation number counter for the 
%                   '\rndeqno', '\rndleqno', '\rdeqno', and '\rdleqno' commands.
%                   The argument of '\rndeqno' follows the same rules as that of
%                   '\reqno'.  When used with the '\label{FOOO}' command, a
%                   reference to FOOO will only return the partial equation
%                   number.  To make a complete reference to an equation
%                   which has a '\rndeqno' command, say '\ref{FOO}\ref{FOOO}'. 
% 
%   \rndleqno{FOO}  same as '\rndeqno{FOO}' but left-aligns the equation number.
% 
%   \rdeqno{FOO}    same as '\rndeqno{FOO}' but without resetting any 
%                   equation number counter and giving consecutive partial
%                   equation numbers ('4b', '4c', etc.).
%                   NOTE:  There is nothing preventing the repeated use of
%                   '\rndeqno{FOO}' and '\rdeqno{FOO}' for the same label
%                   FOO.  This will result in numbering such as '3a' (if 
%                   FOO refers to equation '3') occuring several times.
% 
%   \rdleqno{FOO}   same as '\rdeqno{FOO}' but left-aligns the equation number.
% 
%   \mthref{FOO}    same as ordinary '\ref{FOO}' but does not type-set the
%                   '??' in '\bf' font if occurring within mathmode.
%                   'deleq.sty' makes use of this to avoid interruptions when
%                   LaTeX-ing documents containing '\reqno', '\rleqno', 
%                   '\rndeqno', '\rndleqno', '\rdeqno', or '\rdleqno'.  It 
%                   can be used also outside mathmode, and behaves then
%                   just like '\ref{FOO}'.  Warnings are the same as 
%                   when using '\ref{FOO}'.
% 
%
%  The file itself begins here 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  deleq.sty    Version 3.0, June 22, 1994
%  (c) 1994 by Mats Dahlgren  (matsd@physchem.kth.se or mats@fenk.wau.nl)
%  
\typeout{deleq.sty included, version 3.0 (June 22, 1994).  (c) 1994 by Mats Dahlgren}
%% Part 1: Counters etc.
\def\rm{\mathrm}
\newcounter{deleq}[equation]
\newcounter{Deleq}
\newcount\@deqpen
\newcount\@deqcnt
\def\aLph#1{\@aLph{\@nameuse{c@#1}}}
\def\@aLph#1{\ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or
   k\or l\or m\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or
   z\else\@ctrerr\fi}
\def\thedeleq  {\theequation\mathrm{\aLph{deleq}}}
\def\theDeleq  {\mathrm{\aLph{Deleq}}}
\def\@deleqnnum{{\reset@font\rm (\thedeleq)}}
\def\@delleqnnum{\hbox to .01\p@{}\rlap{\reset@font\rm
        \hskip -\displaywidth(\thedeleq)}}
\def\mthref#1{\@ifundefined{r@#1}{\ifmmode \mathrm{??} \else 
  {\reset@font\bf ??} \fi\@warning {Reference `#1' on page \thepage \space
  undefined}}{\edef\@tempa{\@nameuse{r@#1}}\expandafter 
  \@car\@tempa \@nil\null}}
%% Part 2:  \nydeleqno and \deleqno, with leftists
\def\nydeleqno{\refstepcounter{equation}\refstepcounter{deleq}
  \let\@currentlabel\thedeleq \eqno (\thedeleq)}
\def\deleqno{\refstepcounter{deleq} \let\@currentlabel\thedeleq 
  \eqno (\thedeleq)}
\def\nydelleqno{\refstepcounter{equation}\refstepcounter{deleq}
  \let\@currentlabel\thedeleq \leqno (\thedeleq)}
\def\delleqno{\refstepcounter{deleq} \let\@currentlabel\thedeleq 
  \leqno (\thedeleq)}
%% Part 3:  \reqno, \rndeqno, and \rdeqno, with leftists
\newcommand{\reqno}[1]{\setcounter{Deleq}{-1}\refstepcounter{Deleq}
   \eqno (\mthref{#1}) }
\newcommand{\rdeqno}[1]{\refstepcounter{Deleq}
   \eqno (\mthref{#1}\theDeleq)}
\newcommand{\rndeqno}[1]{\setcounter{Deleq}{0}\refstepcounter{Deleq}
   \eqno (\mthref{#1}\theDeleq)}
\newcommand{\rleqno}[1]{\setcounter{Deleq}{-1}\refstepcounter{Deleq}
   \leqno (\mthref{#1}) }
\newcommand{\rdleqno}[1]{\refstepcounter{Deleq}
   \leqno (\mthref{#1}\theDeleq)}
\newcommand{\rndleqno}[1]{\setcounter{Deleq}{0}\refstepcounter{Deleq}
   \leqno (\mthref{#1}\theDeleq)}
%% Part 4:  'deqarr' environment 
\def\@deqncr{{\ifnum0=`}\fi\@ifstar{\global\@deqpen\@M
    \@ydeqncr}{\global\@deqpen\interdisplaylinepenalty \@ydeqncr}} 
\def\@ydeqncr{\@ifnextchar [{\@xdeqncr}{\@xdeqncr[\z@]}} 
\def\@xdeqncr[#1]{\ifnum0=`{\fi}\@@deqncr
   \noalign{\penalty\@deqpen\vskip\jot\vskip #1\relax}}
\def\@@deqncr{\let\@tempa\relax
    \ifcase\@deqcnt \def\@tempa{& & &}\or \def\@tempa{& &}%
      \else \def\@tempa{&}\fi
     \@tempa \if@eqnsw\@deleqnnum\stepcounter{deleq}\fi
     \global\@eqnswtrue\global\@deqcnt\z@\cr}  
\def\deqarr{\stepcounter{equation}\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@deqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
\def\enddeqarr{\@@deqncr\egroup
      \global\advance\c@deleq\m@ne$$\global\@ignoretrue}
%% Part 4b:  'dleqarr' environment 
\def\@dleqncr{{\ifnum0=`}\fi\@ifstar{\global\@deqpen\@M
    \@ydleqncr}{\global\@deqpen\interdisplaylinepenalty \@ydleqncr}} 
\def\@ydleqncr{\@ifnextchar [{\@xdleqncr}{\@xdleqncr[\z@]}} 
\def\@xdleqncr[#1]{\ifnum0=`{\fi}\@@dleqncr
   \noalign{\penalty\@deqpen\vskip\jot\vskip #1\relax}}
\def\@@dleqncr{\let\@tempa\relax
    \ifcase\@deqcnt \def\@tempa{& & &}\or \def\@tempa{& &}%
      \else \def\@tempa{&}\fi
     \@tempa \if@eqnsw\@delleqnnum\stepcounter{deleq}\fi
     \global\@eqnswtrue\global\@deqcnt\z@\cr}  
\def\dleqarr{\stepcounter{equation}\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@dleqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
\def\enddleqarr{\@@dleqncr\egroup
      \global\advance\c@deleq\m@ne$$\global\@ignoretrue}
%% Part 5:  'ddeqar' environment 
\def\ddeqar{\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@deqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr} 
\def\endddeqar{\enddeqarr}
%% Part 5b:  'ddleqar' environment 
\def\ddleqar{\stepcounter{deleq}
  \let\@currentlabel\thedeleq
  \global\@eqnswtrue\m@th
  \global\@deqcnt\z@\tabskip\@centering\let\\\@dleqncr
  $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@deqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@deqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr} 
\def\endddleqar{\enddleqarr}
%% Part 6:  'deqn' and 'ddeqn' environments, with leftists
\def\deqn{$$\refstepcounter{equation}\stepcounter{deleq} 
  \let\@currentlabel\thedeleq}
\def\enddeqn{\eqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
\def\ddeqn{$$\refstepcounter{deleq} \let\@currentlabel\thedeleq}
\def\endddeqn{\eqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
\def\dleqn{\deqn}
\def\enddleqn{\leqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
\def\ddleqn{\ddeqn}
\def\endddleqn{\leqno \hbox{\@deleqnnum} $$\global\@ignoretrue}
%% Part 7:  \nydeqno and \heqno
\def\nydeqno{\stepcounter{equation}\stepcounter{deleq}}
\def\heqno{\stepcounter{equation}}
%% END of it all!
